<!-- <template>
	<view class="container">
		</uni-list>
		<uni-list>
			<uni-list-item v-for="item,index in avatarList" :key="item.id" :title="item.name" :thumb="item.url"
				:clickable=true @click="goToChatPage" thumbSize="lg">
				<view slot="content">{{item.message}}</view>
			</uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				avatarList: [{
						url: '/static/image/01.webp',
						message: 3
					},
					{
						url: '/static/image/02.jpg',
						message: 1
					},
					{
						url: '/static/image/03.jpg',
						message: 1
					}
				],
				classmateList: []
			}
		},
		methods: {
			goToChatPage(item) {
				// 需要传递一个 userId 参数  
				uni.navigateTo({
					url: '/pages/chat/chat' 
				});
			}
		},
		onLoad() {
			uni.request({
				url: 'http://localhost:8090/freshmenapp/user/list',
				method: 'POST',
				data: {},
				success: res => {
					if (res.data.success) {
						this.avatarList = res.data.list.map((item, index) => {
							return {
								...item,
								...this.avatarList[index]
							}
						})
					}
				},
				fail: () => {},
				complete: () => {}
			});
		}
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
	.uni-list-item__content {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	
	.uni-list-item__title {
		flex: 1;
	}
	
	.uni-list-item__content > * {
		margin-top: 5px;
	}
  
</style> -->

<template>
	<view class="content">
		<uni-list>
			<uni-list-item v-for="item,index in list" :key="index" :title="item.name" :note="item.department" clickable
				@click="tomessage(item.id)">
			</uni-list-item>

		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				"list": [],
			}
		},
		methods: {
			tomessage(itemid) {

				uni.navigateTo({
					url: '../classmatedatail/classmatedatail?itemid=' + itemid
				});
			}
		},
		onLoad() {
			uni.request({
				url: 'http://localhost:8090/freshmenapp/user/list',
				method: 'POST',
				data: {},
				success: res => {
					if (res.data.success === true) {
						this.list = res.data.list
					}
				},
				fail: (err) => {
					uni.showToast({
						title: '网络错误',
						icon: 'error'
					});
				},
				complete: () => {}
			});
		}
	}
</script>

<style>
	/deep/ .uni-badge {
		background-color: red;
	}
</style>